/*
 * @Descripttion: 熊大写的
 * @version: 1.0.0
 * @Author: xt_xiong
 * @Date: 2022-01-18 15:28:08
 * @LastEditors: xt_xiong
 * @LastEditTime: 2022-01-20 15:11:57
 */

import { status } from '@/api/hmmm/constants'
import { hasPermissionOfPoint } from '@/utils/permission'
import { changeState } from '@/api/hmmm/directorys.js'
export default {
  data () {
    return {
      status: status
    }
  },
  methods: {
    // 检查权限函数
    async handleStatus (val) {
      console.log(val)
      var status = ''
      if (val.state === 1) {
        val.state = 0
        status = '已禁用'
      } else {
        val.state = 1
        status = '已启用'
      }
      var data = {
        id: val.id,
        state: val.state
      }
      await changeState(data).then((response) => {
        this.$message.success(`${status}`)
        // window.location.reload()
      })
    }
  },
  directives: {
    // 自定义检查权限点指令
    permission: {
      inserted: function (el, binding) {
        const point = binding.value
        if (!hasPermissionOfPoint(point)) {
          el.style.display = 'none'
        }
      }
    }
  }
}
